<?php
/*
 * planning/index.phtml
 */
?>
<?php
$title = "Planning Semaine";
$this->headTitle($title);

// Variables
$site = $this->site;
?>
<div class="content-head">
    <h3>
	Gestion des <b><?php echo $title; ?></b> pour le site
	<a href="#" id="site" data-type="select"><?php echo $site->libelle; ?></a>
	<img src='<?php echo $this->basePath() . '/img/rhx/refresh-16x16.png' ?>' title="Actualiser la liste" class='rhx-refresh' onclick="return refresh();">
    </h3>
</div>

<form id="siteForm" action="#" method="post">
    <input type="hidden" id="data-site" name="site" value="<?php echo $site->id; ?>">
</form>

<form id="planningForm" action="#" method="post">
    <table class="table">
	<tr>
	    <td width="12%" class="tdLeft">Jours</td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="lundi" checked="checked">Lun</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="mardi" checked="checked">Mar</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="mercredi" checked="checked">Mer</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="jeudi" checked="checked">Jeu</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="vendredi" checked="checked">Ven</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="samedi" checked="checked">Sam</label></td>
	    <td width="12%" style="text-align: center"><label><input type="checkbox" class="styled" name="dimanche" checked="checked">Dim</label></td>
	</tr>
    </table>
    <input type="hidden" id="debut" name="debut" value="0000-00-00">
    <input type="hidden" id="fin" name="fin" value="0000-00-00">
    <input type="hidden" id="site_id" name="site_id" value="<?php echo $site->id; ?>">
</form>

<div class="content-body">
    <!-- AJAX CONTENT -->
    <div id="content-data">
	<!-- AJAX LOADING -->
    </div>
</div>

<!-- SCRIPTS -->
<script type="text/javascript">
	    // Démarrage
	    $(function() {
		// Lien Site éditable
		$('#site').editable({
		    title: "",
		    source: "<?php echo $this->url('RHX/default', array('controller'	 => 'employe', 'action'	 => 'jsonSiteList')) ?>",
		    validate: function(value) {
			$('#data-site').val(value);
			refresh();
			changeSite(value);
		    }
		});
		// Affichage par défaut
	    <?php if ($this->refresh): ?>
    		refresh();
	    <?php endif; ?>
	    });
	    // Rafraichir la page
	    function refresh() {
		ajax = $.ajax({
		    type: 'post',
		    url: '<?php echo $this->url('RHX/default', array('controller'	 => 'planning', 'action'	 => 'loadIndex')) ?>',
		    data: $('#siteForm').serialize() + "&dnastee=" + "dna"
		});
		ajax.success(function(data) {
		    //alert($('#content-data').html());
		    $('#content-data').html(data).show('normal');
		    //alert($('#content-data').html());
		});
		ajax.error(function() {
		    $('#content-data').html("<div class='rh-error'>Contenu Impossible à charger</div>");
		});

		return false;
	    }
</script>

<!-- STYLES -->
<style type="text/css">
    td.tdLeft {
	background: none repeat scroll 0 0 #F2F2F2;
	color: #FF0000;
	font-family: century gothic;
	font-size: 16px;
	font-weight: normal;
	text-align: center;
	text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
	width: 100px;
    }
    .ui-tabs .ui-tabs-panel{
	padding: 1em 0.4em;
    }
    .thick-left{
	border-left-width: 2px;
    }
    .thick-right{
	border-right-width: 2px;
    }
    .thick-both{
	border-left-width: 2px;
	border-right-width: 2px;
    }
    .jaune1{
        background: #fff67f;
    }
    .jaune2{
        background: #ffee05;
    }
    .jaune3{
        background: #ffe84c;
	font-weight: bolder;
    }
    <?php foreach ($this->codes as $code): ?>
    .<?php echo $code->code; ?>{background: <?php echo $code->couleur; ?>; text-align: center;}
<?php endforeach; ?>
    .periode-now{
	font-weight: bolder;
    }
</style>